<?php
/**
 * Created by PhpStorm.
 * User: zzw
 * Date: 17-4-20
 * Time: 下午5:48
 */
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Company_board_model extends MY_Model {

    protected $table = 'company_board';
    public function get_all($where=false,$fields='*',$order=false,$table=FALSE){
        if (!$table) {
            $table = $this->table;
        }
        $this->db->select($fields)->from($table);
        if ($where) {
            $this->db->where($where);
        }
        if ($order) {
            if (is_array($order)) {
                foreach ($order as $k => $v){
                    $this->db->order_by($k,$v);
                }
            }else if(is_string($order)){
                $this->db->order_by($order);
            }
        }
        $query =$this->db->get();
        return $query->result_array();
    }
    public function get_one($where, $fields = "*", $table = false) {
        if (!$table) {
            $table = $this->table;
        }
        if (!$where) {
            return false;
        }
        $this->db->select($fields)->from($table);
        if (!is_numeric($where)) {
            $this->db->where($where);
        }
        $query = $this->db->get();
        $row = $query->row_array();
        return $row;
    }
}